package com.metrics.objects;

import java.util.*;

import com.database.objects.*;

public enum Metric {

	COUNTER_OF_ELEMENTS("NUMBER"), CYCLOMATIC_COMPLEXITY("CYCLOMATIC COMPLEXITY"), CONSTANTINE_COHESION("LACK OF COHESION OF");

	private String text;

	private Metric(String text) {
		this.text = text;
	}

	public String getText() {
		return text;
	}

	public boolean isCounterOfElements() {
		return equals(COUNTER_OF_ELEMENTS);
	}

	public boolean isCyclomaticComplexity() {
		return equals(CYCLOMATIC_COMPLEXITY);
	}

	public static Metric valueOfText(String text) {
		for (Metric metric : values()) {
			if (metric.getText().equals(text)) {
				return metric;
			}
		}
		return null;
	}

	public static List<String> getSizeMetrics() {
		List<String> metrics = new ArrayList<String>();
		for (Type type : VersionRepository.TYPES) {
			for (Status status : VersionRepository.STATUS) {
				String metric = COUNTER_OF_ELEMENTS.getText() + " OF " + status.getText() + " " + type.getText();
				metrics.add(metric);
			}
		}

		for (Type type : TrackerRepository.TYPES) {
			for (Status status : TrackerRepository.STATUS) {
				String metric = COUNTER_OF_ELEMENTS.getText() + " OF " + status.getText() + " " + type.getText();
				metrics.add(metric);
			}
		}
		return metrics;
	}

	public static List<String> getQualityMetrics() {
		List<String> metrics = new ArrayList<String>();
		for (Type type : VersionRepository.TYPES) {
			for (Status status : VersionRepository.STATUS) {
				String metric = CYCLOMATIC_COMPLEXITY.getText() + " OF " + status.getText() + " " + type.getText();
				metrics.add(metric);
			}
		}
		return metrics;
	}

}